package com.molyfun.parents.activity.common;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.molyfun.parents.R;
import com.molyfun.parents.activity.common.attachment.CartViewer;
import com.molyfun.parents.rest.bean.MediaobjectlistBean;

import java.util.ArrayList;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by william(liuchao.hit@gmail.com).
 */
public class AttachViewerActivity extends BaseActivity implements View.OnClickListener{

    @InjectView(R.id.base_title_left)
    ImageView mBack;
    @InjectView(R.id.cart_list)
    CartViewer mCartViewer;

    private static final String FLAG_ATTACHMENT_LIST = "attachment_list";
    private ArrayList<MediaobjectlistBean> mList;

    public static final void startActivity(Context context, ArrayList<MediaobjectlistBean> mediaobjectlistBeenList) {
        Intent intent = new Intent();
        intent.setClass(context, AttachViewerActivity.class);
        intent.putParcelableArrayListExtra(FLAG_ATTACHMENT_LIST, mediaobjectlistBeenList);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_attach_viewer);
        ButterKnife.inject(this);
        getSupportActionBar().setTitle("");

        mList = getIntent().getParcelableArrayListExtra(FLAG_ATTACHMENT_LIST);
        mBack.setOnClickListener(this);
        if(mList != null && mList.size() > 0){
            mCartViewer.initData(mList);
        }else{
            toast("没有数据");
            finish();
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.base_title_left:
                finish();
                break;
        }
    }
}
